package com.sc.nft.admin.controller;

import com.sc.nft.admin.request.IdRequest;
import com.sc.nft.entity.dto.DaoRewardsPropsQueryDTO;
import com.sc.nft.entity.vo.DaoRewardsPropsVO;
import com.sc.nft.service.DaoRewardsPropsService;
import com.sc.nft.sup.PageResult;
import com.sc.nft.sup.Result;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@Slf4j
@RequiredArgsConstructor
@RestController
@RequestMapping("/admin/rewards/props")
@Api(tags = "奖励道具模块")
public class DaoRewardsPropsController {

    private final DaoRewardsPropsService daoRewardsPropsService;

    @PostMapping("/saveBatch")
    @ApiOperation("批量保存道具")
    public Result saveBatch(@ApiParam(value = "道具ID列表", required = true) @RequestBody List<Long> propsList) {
        return Result.success(daoRewardsPropsService.saveBatch(propsList));
    }

    @PostMapping("/remove")
    @ApiOperation("删除道具")
    public Result remove(@RequestBody @Validated IdRequest idRequest) {
        return Result.success(daoRewardsPropsService.remove(idRequest.getId()));
    }

    @PostMapping("/page")
    @ApiOperation("分页查询奖励道具")
    public PageResult<DaoRewardsPropsVO> page(@RequestBody DaoRewardsPropsQueryDTO queryDTO) {
        return PageResult.success(daoRewardsPropsService.page(queryDTO.toMp()));
    }
}
